﻿using System;
using System.Collections.Generic;
using System.Data;
using ContractManager.Entity;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsAttachDocumentWorks
    {
        public static List<AttachDocumentWorks> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.AttachDocumentWorks.Select(db);
            }
            
        }

        public static DataTable GetAll()
        {
            using (var db = Sys.NewDb())
            {
                const string commandText = "EXEC dbo.usp_AttachDocumentWorks_GetAll";
                return db.ExecuteDataTable(commandText);
            }
        }

        

        public static void Insert(AttachDocumentWorks capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<AttachDocumentWorks>(capital, EnumSaveMode.Requery);
            }
            
        }

        public static void Update(AttachDocumentWorks capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<AttachDocumentWorks>(capital);
            }
            
        }

        public static AttachDocumentWorks SelectByPk(Int32 attDocId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<AttachDocumentWorks>(string.Format("AttDocWorkId={0}", attDocId));
            }
            
        }

        public static int DeleteByPk(Int32 attDocId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<AttachDocumentWorks>(string.Format("AttDocWorkId={0}", attDocId));
            }
            
        }
    }
}
